"""Promethues监控指标"""
from common.package.prometheus import Prometheus


class PrometheusMetric(Prometheus):

    StatusRunTime = '/api/v1/status/runtimeinfo'
    StatusBuildInfo = '/api/v1/status/buildinfo'
    StatusTSDB = '/api/v1/status/tsdb'

    def metric(self):
        is_ready = self.is_ready()

        runtime = self.custom(self.StatusRunTime, method='GET')
        buildinfo = self.custom(self.StatusBuildInfo, method='GET')
        tsdb = self.custom(self.StatusTSDB, method='GET')

        return {
            'ready': is_ready,
            'runtime': runtime.get('data', {}),
            'buildinfo': buildinfo.get('data', {}),
            'tsdb': tsdb.get('data', {}),
        }


if __name__ == '__main__':
    prometheus_metric = PrometheusMetric(base_url='http://192.168.101.79:3090')
    a = prometheus_metric.metric()
    print(a)
